package com.itboye.mengwu.data.presenter;

import java.util.List;
import java.util.Observer;

import com.itboye.core.interfaces.ICompleteListener;
import com.itboye.core.object.BasePresenter;
import com.itboye.core.object.ResultEntity;
import com.itboye.mengwu.app.ui.main.MainPresenter;
import com.itboye.mengwu.data.interfaces.IBiaoQian;
import com.itboye.mengwu.data.model.BiaoQianModel;
import com.itboye.mengwu.data.repository.BiaoQianRepository;

public class BiaoQianPresenter extends BasePresenter implements
		IBiaoQian<BiaoQianModel> {
	public static final String addBiaoQIan_success = MainPresenter.class
			.getName() + "_addBiaoQIan_success";
	public static final String addBiaoQIan_fail = MainPresenter.class.getName()
			+ "_addBiaoQIan_fail";
	public static final String queryBiaoQIan_success = MainPresenter.class
			.getName() + "_queryBiaoQIan_success";
	public static final String queryBiaoQIan_fail = MainPresenter.class
			.getName() + "_queryBiaoQIan_fail";

	public BiaoQianPresenter(Observer observer) {
		super(observer);
		// TODO Auto-generated constructor stub
	}

	@Override
	public void add(BiaoQianModel model) {
		// TODO Auto-generated method stub
		IBiaoQian<BiaoQianModel> biaoQian = new BiaoQianRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(addBiaoQIan_success);
						BiaoQianPresenter.this.setChanged();
						BiaoQianPresenter.this.notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(addBiaoQIan_fail);
						BiaoQianPresenter.this.setChanged();
						BiaoQianPresenter.this.notifyObservers(result);
					}
				});
		biaoQian.add(model);
	}

	@Override
	public void delete(BiaoQianModel model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void update(BiaoQianModel model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void getInfo(BiaoQianModel model) {
		// TODO Auto-generated method stub

	}

	@Override
	public List<BiaoQianModel> queryYouHuiQuan(BiaoQianModel model) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void QueryBiaoQian(String uid, String sort, String number) {
		// TODO Auto-generated method stub
		IBiaoQian<BiaoQianModel> biaoQian = new BiaoQianRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(queryBiaoQIan_success);
						BiaoQianPresenter.this.setChanged();
						BiaoQianPresenter.this.notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(queryBiaoQIan_fail);
						BiaoQianPresenter.this.setChanged();
						BiaoQianPresenter.this.notifyObservers(result);
					}
				});
		biaoQian.QueryBiaoQian(uid, sort, number);
	}

}
